import request from '@/utils/request'

export function fetchCategoryTreeList(query) {
  return request({
    url: '/admin/product-category-tree-list',
    method: 'get',
    params: query
  })
}

export function fetchCategoryTree(query) {
  return request({
    url: '/admin/product-category-tree',
    method: 'get',
    params: query
  })
}

export function fetchCategoryAll(query) {
  return request({
    url: '/admin/product-category-all',
    method: 'get',
    params: query
  })
}

export function fetchList(query) {
  return request({
    url: '/admin/product-category',
    method: 'get',
    params: query
  })
}

export function categorytree(id) {
  return request({
    url: '/admin/categorytree',
    method: 'get',
    params: { 'cat_id': id }
  })
}

export function createCategory(data) {
  return request({
    url: '/admin/product-category',
    method: 'post',
    data
  })
}

export function updateCategory(id, data) {
  return request({
    url: '/admin/product-category/' + id,
    method: 'put',
    data
  })
}

export function deleteCategory(id) {
  return request({
    url: '/admin/product-category/' + id,
    method: 'delete'
  })
}

export function fetchCategory(id) {
  return request({
    url: '/admin/product-category/' + id,
    method: 'get',
    params: { }
  })
}

export function fetchSort(id, sort) {
  return request({
    url: '/admin/product-category-sort/' + id,
    method: 'put',
    params: { sort }
  })
}